package com.shell.arouter.demo.litho

import android.content.Context
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.durian.base.frame.easyrouter.EasyRouter
import com.facebook.litho.ComponentContext
import com.facebook.litho.LithoView
import com.facebook.litho.sections.SectionContext
import com.facebook.litho.sections.widget.RecyclerCollectionComponent
import com.shell.arouter.demo.IHomeAction
import com.shell.arouter.extend.PATH_LITHO
import com.shell.arouter.ui.FragmentCommon

/**
 * 说明：ActionLitho
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020-01-18 17:32
 * <p/>
 * 版本：version 1.0
 */
class ActionLitho : IHomeAction{
    override fun todo() {
        EasyRouter.buildByFragment(PATH_LITHO).navigation()
    }

    override fun name(): String {
        return "Litho"
    }

}

@Route(path = PATH_LITHO)
class FragmentLitho : FragmentCommon(){

    override fun isShowTitleBar(): Boolean {
        return true
    }

    override fun bindRootView(context: Context?): View {
        val cxt = ComponentContext(context)
        val component = RecyclerCollectionComponent.create(cxt)
                .disablePTR(false)
                .section(ListSection.create(SectionContext(cxt)))
                .build()
        return LithoView.create(cxt,component)
    }


    override fun bindTitleBarText(): String {
        return "Retrofit"
    }

}

//@LayoutSpec
//class ListItemSpec{
//
//    companion object{
//        @OnCreateLayout
//        fun onCreateLayout(c : ComponentContext) : Component{
//            return Column.create(c)
//                    .paddingDip(YogaEdge.ALL,16f)
//                    .backgroundColor(UIUtils.getColor(R.color.base_app_theme_color))
//                    .child(Text.create(c).text("Hello word").textSizeSp(40f))
//                    .child(Text.create(c).text("Litho tutorial").textSizeSp(20f))
//                    .build()
//        }
//    }
//
//}